<!--{template admin/header_tpl}-->

<div class="mainarea">
	<div class="maininner">
		<div class="tabs_header">
			<ul class="tabs">
				<li><a href="<!--{eval echo base_url()}-->admin/admin_goods/index/{$thevalue[aid]}"><span>浏览商品</span></a></li>
				<li class="null"><a href="<!--{eval echo base_url()}-->admin/admin_goods/add_goods/{$thevalue[aid]}">添加商品</a></li>
			</ul>
		</div>
<!--加载数据-->
		<form action="<!--{eval echo base_url()}-->admin/admin_goods/edit_goods/$thevalue[gid]" method="post" accept-charset="utf-8" enctype="multipart/form-data">
			<div class="bdrcontent">
				<table class="formtable" cellspacing="5" cellpadding="5">
					<tr>
						<th style="width:12em;">商品名称</th>
						<td><input type="text" name="set[name]" value="$thevalue[name]" size="30"></td>
					</tr>
					<!--url img-->
					<!--{if $thevalue[imageurl]}-->
						<tr id="url_display" <!--{if $thevalue[img_mode] ==1 }--> style="display:none;"<!--{/if}-->>
							<th style="width:12em;">图片</th>
							<td><img src="$thevalue[imageurl]"></td>
						</tr>
					<!--{/if}-->
					<tr id="url_action" <!--{if $thevalue[img_mode] ==1 }--> style="display:none;"<!--{/if}-->>
						<th>图片链接</th>
						<td><input type="text" name="set[imageurl]" value="$thevalue[imageurl]" size="80"></td>
					</tr>
					<!--upload img-->
					<!--{if $thevalue[uploadimg]}-->
						<tr id="upload_display" <!--{if $thevalue[img_mode] !=1 }--> style="display:none;"<!--{/if}-->>
							<th style="width:12em;">上传图片</th>
							<td><img src="$thevalue[uploadimg]"></td>
						</tr>
					<!--{/if}-->
					<tr id="upload_action" <!--{if $thevalue[img_mode] !=1 }--> style="display:none;"<!--{/if}-->>
						<th>上传图片</th>
						<td><input type="file" name="userfile" value="" id="image" size="20"></td>
					</tr>
					<tr>
						<th>图片操作</th>
						<td>外链图片<input type="radio" name="set[img_mode]" value="0" onclick="swich_img_mode();" <!--{if $thevalue[img_mode] !=1}--> checked <!--{/if}-->>
							上传图片<input type="radio" name="set[img_mode]" value="1" onclick="swich_img_mode();" <!--{if $thevalue[img_mode] ==1}--> checked <!--{/if}-->>
						</td>
					</tr>
					<tr>
						<th>链接地址</th>
						<td><input type="text" name="set[url]" value="$thevalue[url]" size="80"></td>
					</tr>
					<tr>
						<th>品牌</th>
						<td>
							<select name="set[brandid]">
									<option value="0" >请选品牌</option>
								<!--{loop $brands $brand}-->
									<option value="{$brand['bid']}" <!--{if $thevalue[brandid] == $brand[bid]}--> selected<!--{/if}-->>{$brand[firstletter]}-{$brand['name']}</option>
								<!--{/loop}-->
							</select>
						</td>
					</tr>
					<tr>
						<th>分类</th>
						<td>
							<select name="set[catid]">
								<option value="0" >请选择分类</option>
								<!--{loop $category $cat}-->
									
									<option value="{$cat[catid]}" <!--{if $thevalue[catid] == $cat[catid]}--> selected <!--{/if}-->>{$cat[name]}</option>
								<!--{/loop}-->
							</select>
						</td>
					</tr>
					<tr>
						<th>现价</th>
						<td><input type="text" id= "price" name="set[price]" value="$thevalue[price]" size="10" onkeyup="count_discount()">打折之后的价格</td>
					</tr>
					<tr>
						<th>市场价格</th>
						<td><input type="text" id="marketprice" name="set[marketprice]" value="$thevalue[marketprice]" size="10" onkeyup="count_discount()"></td>
					</tr>
					<tr>
						<th>折扣</th>
						<td><input type="text" id="discount" name="set[discount]" value="$thevalue[discount]" size="10"></td>
					</tr>
				</table>
			</div>
			<input type="hidden" name="aid" value="{$thevalue[aid]}" id="aid">
		<div class="footactions">
		<input type="submit" name="thevaluesubmit" value="提交" class="submit">
		</div>
		</form>
	</div>
</div>
<div class="side">
	<!--{template admin/side}-->
</div>
<script type="text/javascript">
function count_discount(){
	var price = $("#price").val();
	var marketprice = $("#marketprice").val();
	if (price && marketprice) {
		$('#discount').val(fomatFloat((price/marketprice)*10, 1));
	};	
}

function fomatFloat(src,pos){     
	return Math.round(src*Math.pow(10, pos))/Math.pow(10, pos);     
}
function swich_img_mode(){
	$('#url_display').toggle();
	$('#url_action').toggle();
	$('#upload_display').toggle();
	$('#upload_action').toggle();
}
</script>
<!--{template admin/footer_tpl}-->